﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//
using System.ComponentModel;

namespace Mp3Edit
{
    public class CData
    {
        public bool Marker {get; set;}
        private string _Disk_FullFileName;
        public string Disk_FullFileName { get { return null == _Disk_FullFileName ? "" : _Disk_FullFileName; } set { _Disk_FullFileName = null == value ? "" : value; } }
        private string _FileTrack;
        public string FileTrack { get { return null == _FileTrack ? "" : _FileTrack; } set { _FileTrack = null == value ? "" : value; } }
        public bool FileTrack_Changed {get; set;}
        public string FileName { get { return null == _FileName ? "" : _FileName; } set { _FileName = null == value ? "" : value; } }
        private string _FileName;
        public bool FileName_Changed {get; set;}
        private string _FileExt;
        public string FileExt { get { return null == _FileExt ? "" : _FileExt; } set { _FileExt = null == value ? "" : value; } }
        private string _tagTrack;
        public string tagTrack { get { return null == _tagTrack ? "" : _tagTrack; } set { _tagTrack = null == value ? "" : value; } }
        public bool tagTrack_Changed {get; set;}
        private string _tagTitle;
        public string tagTitle { get { return null == _tagTitle ? "" : _tagTitle; } set { _tagTitle = null == value ? "" : value; } }
        public bool tagTitle_Changed {get; set;}
        private string _tagArtist;
        public string tagArtist { get { return null == _tagArtist ? "" : _tagArtist; } set { _tagArtist = null == value ? "" : value; } }
        public bool tagArtist_Changed {get; set;}
        private string _tagAlbum;
        public string tagAlbum { get { return null == _tagAlbum ? "" : _tagAlbum; } set { _tagAlbum = null == value ? "" : value; } }
        public bool tagAlbum_Changed {get; set;}
        private string _tagYear;
        public string tagYear { get { return null == _tagYear ? "" : _tagYear; } set { _tagYear = null == value ? "" : value; } }
        public bool tagYear_Changed {get; set;}
        private string _tagGenre;
        public string tagGenre { get { return null == _tagGenre ? "" : _tagGenre; } set { _tagGenre = null == value ? "" : value; } }
        public bool tagGenre_Changed {get; set;}
        public Int32 Flags { get; set; }
        //
        //public string tagGenre { get {return null==_?"":_;} set{_=null==value?"":value;} }
        //
        public CData(string Disk_FullFileNam, string FileTrack, string FileName, string FileExt, string tagTrack, string tagTitle, string tagArtist, string tagAlbum, string tagYear, string tagGenre)
        {
            this.Marker = false;
            this.FileTrack_Changed = false;
            this.FileName_Changed = false;
            this.tagTrack_Changed = false;
            this.tagTitle_Changed = false;
            this.tagArtist_Changed = false;
            this.tagAlbum_Changed = false;
            this.tagYear_Changed = false;
            this.tagGenre_Changed = false;
            this.Flags = 0;
            //
            this.Disk_FullFileName=Disk_FullFileNam;
            this.FileTrack=FileTrack;
            this.FileName=FileName;
            this.FileExt=FileExt;
            this.tagTrack=tagTrack;
            this.tagTitle=tagTitle;
            this.tagArtist=tagArtist;
            this.tagAlbum = tagAlbum;
            this.tagYear=tagYear;
            this.tagGenre = tagGenre;
            //;
        }
        //
        public static string ColumnName(int n)
        {
            switch (n)
            {
                case 0: return "Marker";
                case 1: return "Disk_FullFileName";
                case 2: return "FileTrack";
                case 3: return "FileTrack_Changed";
                case 4: return "FileName";
                case 5: return "FileName_Changed";
                case 6: return "FileExt";
                case 7: return "tagTrack";
                case 8: return "tagTrack_Changed";
                case 9: return "tagTitle";
                case 10: return "tagTitle_Changed";
                case 11: return "tagArtist";
                case 12: return "tagArtist_Changed";
                case 13: return "tagAlbum";
                case 14: return "tagAlbum_Changed";
                case 15: return "tagYear";
                case 16: return "tagYear_Changed";
                case 17: return "tagGenre";
                case 18: return "tagGenre_Changed";
                case 19: return "Flags";
            }
            return "";
        }
        //
        public static void Sort(BindingList<CData> LD)
        {
            List<CData> ll = new List<CData>();
            //
            ll = LD.ToList<CData>();
            ll = ll.OrderBy(x => x.FileTrack).ThenBy(p => p.FileName).ToList<CData>();
            //
            bool oldRaise = LD.RaiseListChangedEvents;
            LD.RaiseListChangedEvents = false;
            try {
                LD.Clear();
                foreach (CData l in ll) LD.Add(l);
            } 
            finally {
                LD.RaiseListChangedEvents = oldRaise;
                //ResetBindings();
            }
        }
        //
    }//class
}//namespace
